import pytest

from lr9_9.Base.Base import Base
from selenium.webdriver.common.by import By
import time


class Page(Base):
    #1.打开A3mall网址
    #2.点击登录按钮
    denglu_loc = (By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a')

    def denglu(self):
        self.click(self.denglu_loc)
    #3.输入用户名密码
    username_loc = (By.XPATH,'/html/body/div[4]/div/div[1]/div[2]/form/div[1]/span[2]/input')
    password_loc = (By.NAME,'password')

    def username(self):
        self.send_keys(self.username_loc,'13811033962')

    def password(self):
        self.send_keys(not self.password_loc, '123456')
    #4.输入验证码
    #5.点击登录
    login_loc = (By.CLASS_NAME,'finish-btn')
    def login(self):
        self.click(self.login_loc)
    #6.搜索框输入手机
    shuruk_loc = (By.NAME,'keywords')
    def shuruk(self):
        self.send_keys(self.shuruk_loc,'手机')
    #7.点击搜索，提示搜索成功
    sousuobuttn_loc = (By.CSS_SELECTOR,'search-input-btn')
    def shousuobuttn(self):
        self.click(self.sousuobuttn_loc)


    def test_A3mall_001(self):
        # 1.打开A3mall网址
        self.open_url('http://10.59.9.12:7001/')
        # 2.点击登录按钮
        self.denglu()
        time.sleep(3)
        # 3.输入用户名密码
        self.username()
        self.password()
        # 4.输入验证码
        time.sleep(10)
        # 5.点击登录
        self.login()
        # 6.搜索框输入手机
        self.shuruk()
        time.sleep(2)
        # 7.点击搜索，提示搜索成功
        self.shousuobuttn()
        time.sleep(3)